package Protect;

import Protect.Protect1.ChildClass2;

public class ProtectTest {

    public static void main(String[] args) {
        SuperClass c1 = new ChildClass1("我是SuperClass ChildClass1");
        c1.Show();
        System.out.println(c1.name);
        c1.finalShow();//父类中的 final 方法可以被子类调用，但是不能被子类重写

        ChildClass1 c11 = new ChildClass1("我是ChildClass1");
        c11.Show();
        c11.finalShow();
        System.out.println(c11.name);

        System.out.println("**************************************");

        SuperClass c2 = new ChildClass2("我是SuperClass ChildClass2");
        c2.Show();
        System.out.println(c2.name);

        ChildClass2 c22 = new ChildClass2("我是ChildClass2");
        //c22.Show();//不能访问基类的protected方法，因为子类与基类不在同一包中，除非将继承父类方法设置为public
        System.out.println(c22.name);
    }
}
